#include<iostream>
#include<string>
#include<cstring>
using namespace std;
string s;
int n;
int main()
{
	while (getline(cin, s)) {
		if (s.size() == 0) {
			break;
		}
		bool flag = 0;
		int j = 0;
		int ans = 0;
		int sum = 0;
		int sum1 = 0;
		char ch = ' ';
		for (int i = 0; i < s.size(); i++) {
			if (s[i] >= '0' && s[i] <= '9') {
				ans = ans * 10 + s[i] - '0';
				if (ans >= 256) {
					flag = 1;
					break;
				}
				ch = '0';
			}
			else if (s[i] == '.') {
				if (ch == '.') {
					flag = 1;
					break;
				}
				sum++;
				if (sum > 3) {
					flag = 1;
					break;
				}
				ans = 0;
				sum1++;
				ch = '.';
			}
			else {
				flag = 1;
				break;
			}
		}
		if (sum1 < 3) {
			flag = 1;
		}
		if (flag) {
			cout << "NO" << endl;
		}
		else {
			cout << "YES" << endl;
		}
	}
	return 0;
}